Alfresco offre une vraie alternative Open Source pour la Gestion de Contenu d'Entreprise (ECM) - Gestion de Documents, Collaboration, Gestion des Archives/Enregistrements légaux, Gestion de Contenu Web et Gestion des Documents Numérisés.


===Installation===
==Installation de sun-java6-jdk==
Le paquet sun-java6-jdk est dans les dépots ubuntu.
  sudo -s
  apt-get install sun-java6-jdk
  java -version
  JAVADIR=`ls /usr/lib/jvm | grep java-6-sun-`
  JAVA_HOME="/usr/lib/jvm/${JAVADIR}"

Nous utiliserons la variable JAVA_HOME plus loin dans ce document !

==Installation de Alfresco Labs 3==
  URLALFRESCO=http://eu.dl.alfresco.com/release/labs/build-1526/\
  Alfresco-Labs-3Stable-Linux-x86-Install?dl_file=release/labs/\
  build-1526/Alfresco-Labs-3Stable-Linux-x86-Install
  ALFRESCOINSTALLFILE=`basename $URLALFRESCO`
  mkdir ~/alfresco-download/
  wget -c $URLALFRESCO -O ~/alfresco-download/$ALFRESCOINSTALLFILE
  chmod +x ~/alfresco-download/$ALFRESCOINSTALLFILE
  ~/alfresco-download/$ALFRESCOINSTALLFILE --mode console

==Compilation et installaion de SWFTOOLS==
On telecharge les sources, on compile et on installe:
  URLSWFTOOLS=http://www.swftools.org/swftools-2009-03-08-1844.tar.gz
  SWFTOOLSINSTALLFILE=`basename $URLSWFTOOLS`
  apt-get install  build-essential zlib1g-dev libjpeg62-dev libgif-dev libfreetype6-dev tofrodos
  wget -c $URLSWFTOOLS -O ~/alfresco-download/$SWFTOOLSINSTALLFILE
  SWFTOOLSINSTALLDIR=`cd ~/alfresco-download/ && tar xvzf ~/alfresco-download/$SWFTOOLSINSTALLFILE | awk -F '/' '{print $1}' | sort -u`
  cd ~/alfresco-download//$SWFTOOLSINSTALLDIR && ./configure && make && make install 

==Installation de OpenOffice 3==
Alfresco n'est pas comptatible avec OpenOffice 2.4. Nous devons installer OpenOffice 3
  if [ ! -f "/opt/openoffice.org3/program/soffice" ]
  then
  cd ~/alfresco-download
  ARCH=`uname -m`
  [ "$ARCH" = "x86_64" ] || wget -c http://ftp.sunet.se/pub/Office/OpenOffice.org/localized/fr/3.0.1/OOo_3.0.1_LinuxIntel_install_fr_deb.tar.gz  -O ~/alfresco-download/OOo_3.0.1_LinuxIntel_install_fr_deb.tar.gz
  [ "$ARCH" = "x86_64" ] || wget -c http://ftp.nluug.nl/pub/office/openoffice/localized/fr/3.0.1/OOo_3.0.1_LinuxIntel_langpack_fr_deb.tar.gz  -O ~/alfresco-download/OOo_3.0.1_LinuxIntel_langpack_fr_deb.tar.gz
  [ "$ARCH" = "x86_64" ] && wget -c http://ftp.nluug.nl/pub/office/openoffice/localized/fr/3.0.1/OOo_3.0.1_LinuxX86-64_install_fr_deb.tar.gz     -O ~/alfresco-download/OOo_3.0.1_LinuxIntel_install_fr_deb.tar.gz
  [ "$ARCH" = "x86_64" ] && wget -c http://ftp.nluug.nl/pub/office/openoffice/localized/fr/3.0.1/OOo_3.0.1_LinuxX86-64_langpack_fr_deb.tar.gz    -O ~/alfresco-download/OOo_3.0.1_LinuxIntel_langpack_fr_deb.tar.gz
  mkdir -p ~/alfresco-download/debs/
  cd ~/alfresco-download/debs/ && tar xvzf ~/alfresco-download/OOo_3.0.1_LinuxIntel_install_fr_deb.tar.gz
  cd ~/alfresco-download/debs/ && tar xvzf ~/alfresco-download/OOo_3.0.1_LinuxIntel_langpack_fr_deb.tar.gz
  mkdir -p /var/ooffice-repository/
  for file in `find ~/alfresco-download/debs/ -type f -name "*.deb"`
  do
   cp -uv "$file" /var/ooffice-repository/
  done
  
  cd /var/ && bash -c 'dpkg-scanpackages ooffice-repository/ /dev/null | gzip -9c > ooffice-repository/Packages.gz'
  bash -c 'echo "deb file:/var ooffice-repository/" > /etc/apt/sources.list.d/ooffice.list'
  
  apt-get update
  apt-get remove openoffice.org-core openoffice.org-writer openoffice.org-math \
   openoffice.org-impress openoffice.org-gtk openoffice.org-gnome openoffice.org-draw \
   openoffice.org-common openoffice.org-calc python-uno openoffice.org-emailmerge \
   openoffice.org-style-human ttf-opensymbol openoffice.org-base-core
  for pack in `zcat /var/ooffice-repository/Packages.gz | grep ^Package: | awk '{print $2}'`
  do
  	apt-get -f install
  	apt-get -y --force-yes install  $pack
  	apt-get -f install
  done
  else
  	echo "Nothing to do"
  fi


===Configuration de Alfresco Labs 3===

  function addToFile(){
          str="$1"
          cfgfile="$2"
          echo "Adding string \"$str\" to file $cfgfile"
          if ! grep "^$str" "$cfgfile"
          then
                  bash -c "echo \"$str\" >> $cfgfile"
          fi
  }
  JAVADIR=`ls /usr/lib/jvm | grep java-6-sun-`
  JAVA_HOME="/usr/lib/jvm/${JAVADIR}"
  sed -i "s#^ALF_HOME=.*#ALF_HOME=/opt/Alfresco#g" /opt/Alfresco/alfresco.sh
  sed -i "s#^export JAVA_HOME=.*#export JAVA_HOME=$JAVA_HOME#g"  /opt/Alfresco/alfresco.sh
  sed -i "s#^ALF_HOME=.*#ALF_HOME=/opt/Alfresco#g" /opt/Alfresco/virtual_alf.sh
  sed -i "s#^export JAVA_HOME=.*#export JAVA_HOME=$JAVA_HOME#g" /opt/Alfresco/virtual_alf.sh
  ALFCFGFILE=/opt/Alfresco/tomcat/shared/classes/alfresco/extension/custom-repository.properties
  [ -f "${ALFCFGFILE}.bak" ] || cp  ${ALFCFGFILE} ${ALFCFGFILE}.bak
  dos2unix $ALFCFGFILE
  addToFile  "#Config" $ALFCFGFILE
  addToFile  "img.root=/usr/" $ALFCFGFILE
  addToFile  "swf.exe=/usr/local/bin/pdf2swf"  $ALFCFGFILE
  addToFile  "ooo.exe=/opt/openoffice.org3/program/soffice"  $ALFCFGFILE
  
===Premier usage===
A ce stade, Alfresco est installé. on peut démarrer le service et tester la connexion : http://127.0.0.1:8080/alfresco/
  login : admin
  password : admin

Dépeché vous de **changer le mot de passe du compte admin !!!**

  /opt/Alfresco/alfresco.sh  start
  tail -f  /opt/Alfresco/alfresco.log

===choix de la base de donnée===
Alfresco est comptatible avec la plupart des bases de données actuelle (En effet, il utilise JDBC pour communiquer avec la base). Dans l'exemple ci-dessus, nous n'avons pas configuré de base de donnée. Par défaut Alfresco intégre un serveur de base de donnée Derby.

Nous verrons comment configurer Alfresco avec :
  * MySQL
  * PostgreSQL

==Configuration Alfresco / MySQL==

  HIBFILE=/opt/Alfresco/tomcat/shared/classes/alfresco/extension/custom-hibernate-dialect.properties
  CUSTOREPOPROPERTY=/opt/Alfresco/tomcat/shared/classes/alfresco/extension/custom-repository.properties
  apt-get -y --force-yes install mysql-server
  echo
  echo "Enter MySQL root password"
  bash -c "mysql -p < /opt/Alfresco/extras/databases/mysql/db_setup.sql"
  sed -i "s:^db.driver=:#db.driver=:g" $CUSTOREPOPROPERTY
  addToFile  "db.driver=org.gjt.mm.mysql.Driver" $CUSTOREPOPROPERTY
  sed -i "s:^db.url=:#db.url=:g" $CUSTOREPOPROPERTY
  addToFile  "db.url=jdbc:mysql://localhost/$DBNAME" $CUSTOREPOPROPERTY
  sed -i "s:^db.password=:#db.password=:g" $CUSTOREPOPROPERTY
  addToFile  "db.password=alfresco" $CUSTOREPOPROPERTY
  sed -i "s:^db.username=:#db.username=:g" $CUSTOREPOPROPERTY
  addToFile  "db.username=alfresco" $CUSTOREPOPROPERTY
  sed -i "s:^hibernate.dialect=org.hibernate.dialect.DerbyDialect:#hibernate.dialect=org.hibernate.dialect.DerbyDialect:g" $HIBFILE
  sed -i "s:^#hibernate.dialect=org.hibernate.dialect.MySQLInnoDBDialect:hibernate.dialect=org.hibernate.dialect.MySQLInnoDBDialect:g" $HIBFILE

==Configuration Alfresco / PostgreSQL==

  HIBFILE=/opt/Alfresco/tomcat/shared/classes/alfresco/extension/custom-hibernate-dialect.properties
  CUSTOREPOPROPERTY=/opt/Alfresco/tomcat/shared/classes/alfresco/extension/custom-repository.properties
  apt-get -y --force-yes install postgresql-8.3
  sudo -u postgres bash -c "psql postgres -d template1  -c 'create database alfresco;'"
  sudo -u postgres bash -c "psql postgres -d template1  -c \"create user alfresco with password 'alfresco';\""
  sudo -u postgres bash -c "psql postgres -d template1  -c 'grant all on database alfrescoto alfresco;'"
  wget -c http://jdbc.postgresql.org/download/postgresql-8.3-604.jdbc4.jar -O /opt/Alfresco/tomcat/common/lib//postgresql-8.3-604.jdbc4.jar 
  sed -i "s:^db.driver=:#db.driver=:g" $CUSTOREPOPROPERTY
  addToFile  "db.driver=org.postgresql.Driver" $CUSTOREPOPROPERTY
  sed -i "s:^db.url=:#db.url=:g" $CUSTOREPOPROPERTY
  addToFile  "db.url=jdbc:postgresql://localhost:5432/alfresco" $CUSTOREPOPROPERTY
  sed -i "s:^db.password=:#db.password=:g" $CUSTOREPOPROPERTY
  addToFile  "db.password=alfresco" $CUSTOREPOPROPERTY
  sed -i "s:^db.username=:#db.username=:g" $CUSTOREPOPROPERTY
  addToFile  "db.username=alfresco" $CUSTOREPOPROPERTY
  sed -i "s:^hibernate.dialect=org.hibernate.dialect.DerbyDialect:#hibernate.dialect=org.hibernate.dialect.DerbyDialect:g" $HIBFILE
  sed -i "s:^#hibernate.dialect=org.hibernate.dialect.PostgreSQLDialect:hibernate.dialect=org.hibernate.dialect.PostgreSQLDialect:g" $HIBFILE